home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
usr
/
include
/
sys
/
sem.h.z
/
sem.h
Wrap
C/C++ Source or Header
|
1992-04-03
|
4KB
|
166 lines
#ifndef __SYS_SEM_H__
#define __SYS_SEM_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* Copyright 1990, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
#ident "$Revision: 3.15 $"
/*
** IPC Semaphore Facility.
*/
/*
** Implementation Constants.
*/
#ifdef _KERNEL
#define PSEMN (PZERO + 3) /* sleep priority waiting for greater value */
#define PSEMZ (PZERO + 2) /* sleep priority waiting for zero */
#endif /* _KERNEL */
/*
** Permission Definitions.
*/
#define SEM_A 0200 /* alter permission */
#define SEM_R 0400 /* read permission */
/*
** Semaphore Operation Flags.
*/
#define SEM_UNDO 010000 /* set up adjust on exit entry */
/*
** Semctl Command Definitions.
*/
#define GETNCNT 3 /* get semncnt */
#define GETPID 4 /* get sempid */
#define GETVAL 5 /* get semval */
#define GETALL 6 /* get all semval's */
#define GETZCNT 7 /* get semzcnt */
#define SETVAL 8 /* set semval */
#define SETALL 9 /* set all semval's */
/*
** Structure Definitions.
*/
/*
** There is one semaphore id data structure for each set of semaphores
** in the system.
*/
struct semid_ds {
struct ipc_perm sem_perm; /* operation permission struct */
struct sem *sem_base; /* ptr to first semaphore in set */
ushort sem_nsems; /* # of semaphores in set */
time_t sem_otime; /* last semop time */
time_t sem_ctime; /* last change time */
};
#ifdef _KERNEL
/*
** There is one semaphore structure for each semaphore in the system.
*/
struct sem {
ushort semval; /* semaphore text map address */
sema_t semnwait; /* to wait for non-zero value */
sema_t semzwait; /* to wait for zero value */
short sempid; /* pid of last operation */
short semncnt; /* # awaiting semval > cval */
short semzcnt; /* # awaiting semval = 0 */
};
/*
** There is one undo structure per process in the system.
*/
struct sem_undo {
struct sem_undo *un_np; /* ptr to next active undo structure */
short un_cnt; /* # of active entries */
struct undo {
short un_aoe; /* adjust on exit values */
short un_num; /* semaphore # */
int un_id; /* semid */
} un_ent[1]; /* undo entries (one minimum) */
};
/*
* Macro to generate sem id lock ptr
*/
#define SEMADDR(X) &semsem[X]
#endif /* _KERNEL */
/*
** semaphore information structure
*/
struct seminfo {
int semmni, /* # of semaphore identifiers */
semmns, /* # of semaphores in system */
semmnu, /* # of undo structures in system */
semmsl, /* max # of semaphores per id */
semopm, /* max # of operations per semop call */
semume, /* max # of undo entries per process */
semusz, /* size in bytes of undo structure */
semvmx, /* semaphore maximum value */
semaem; /* adjust on exit max value */
};
/*
** User semaphore template for semop system calls.
*/
struct sembuf {
ushort sem_num; /* semaphore # */
short sem_op; /* semaphore operation */
short sem_flg; /* operation flags */
};
union semun {
int val;
struct semid_ds *buf;
ushort *array;
};
#ifndef _KERNEL
extern int semctl (int, int, int, ...);
extern int semget (key_t, int, int);
extern int semop (int, struct sembuf *, unsigned);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !__SYS_SEM_H__ */